from django.db import models
from django.utils.translation import ugettext_lazy as _
from opinion_extractor.respondent.models import AbstractRespondent


class Student(AbstractRespondent):
    GENDER_CHOICES = (
        ('M', _('Male')), 
        ('F', _('Female')),
    ) 
    gender = models.CharField(
        _('gender'),
        max_length=1,
        blank=True,
        null=True,
        db_index=True, 
        choices=GENDER_CHOICES
    )
    AGE_CHOICES = map(lambda x: (x, x), range(17, 30))
    age = models.PositiveIntegerField(
        _('age'),
        blank=True,
        null=True,
        db_index=True,
        choices=AGE_CHOICES 
    )
    YEAR_CHOICES = map(lambda x: (x, x), range(1, 6))
    year = models.PositiveIntegerField(
        _('year of study'),
        blank=True,
        null=True,
        db_index=True, 
        choices=YEAR_CHOICES, 
    )

    class Meta(AbstractRespondent.Meta):
        verbose_name = _('student')
        verbose_name_plural = _('students')
        
    def __unicode__(self):
        return u"%s (%s - %s): %d years old %s studying %s. year" % (
            self.user,
            self.valid_from,
            self.valid_to,
            self.age,
            self.get_gender_display(),
            self.get_year_display()
        )   
